package com.information.manage.common.constants;

import lombok.Getter;

/**
 * 监听类型枚举
 * 配置文件中配置的base.watchDir中的值为该枚举中的类型
 */
public enum ListenTypeEnum {
    OTHER("other", "其他", 0),
    CONSULTING("consulting", "咨询", 1),
    SHORT_MESSAGE("short_message", "短讯", 2),
    SHORT_ARTICLE("short_article", "短篇", 3),
    ;

    @Getter
    private String type;
    private String des;
    @Getter
    private Integer code;

    ListenTypeEnum(String type, String des, Integer code){
        this.type = type;
        this.des = des;
        this.code = code;
    }

    public static Boolean belongListenType(String type){
        for (ListenTypeEnum value : ListenTypeEnum.values()) {
            if (type.equals(value.type)) return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }

    public static Integer getFileTypeCode(String type){
        for (ListenTypeEnum value : ListenTypeEnum.values()) {
            if (type.equals(value.type)) return value.code;
        }
        return OTHER.code;
    }

    public static String getFileDir(Integer code){
        for (ListenTypeEnum value : ListenTypeEnum.values()) {
            if (code == value.code) return value.type;
        }
        return OTHER.type;
    }

}
